<template>
  <div
    :class="prefixCls"
    class="login-wrapper lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px"
  >
    <video class="login-wrapper-bg-video lt-xl:hidden" muted autoplay>
      <source src="@/assets/video/bg.mp4" type="video/mp4" />
    </video>
    <div class="login-container">
      <div class="login-header">
        <!-- 左上角的 logo + 系统标题 -->
        <div class="relative flex items-center text-white lt-xl:hidden">
          <img alt="" class="mr-10px w-60px" src="@/assets/imgs/logo.png" />
          <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
        </div>
        <div
          class="flex items-center justify-between at-2xl:justify-end at-xl:justify-end"
          style="color: var(--el-text-color-primary)"
        >
          <div class="flex items-center at-2xl:hidden at-xl:hidden">
            <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" />
            <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
          </div>
          <div class="flex items-center justify-end space-x-10px h-48px">
            <ThemeSwitch />
            <LocaleDropdown />
          </div>
        </div>
      </div>

      <!-- 右边的登录界面 -->
      <Transition appear enter-active-class="animate__animated animate__fadeInUp">
        <div
          class="login-form-wrapper m-auto w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px"
        >
          <!-- 账号登录 -->
          <UstcLoginForm class="m-auto h-auto p-30px lt-xl:(rounded-3xl light:bg-white)" />
          <ImrLoginForm class="m-auto h-auto p-30px lt-xl:(rounded-3xl light:bg-white)" />
          <!-- 注册 -->
          <RegisterForm class="m-auto h-auto p-30px lt-xl:(rounded-3xl light:bg-white)" />
        </div>
      </Transition>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { underlineToHump } from '@/utils'

import { useDesign } from '@/hooks/web/useDesign'
import { useAppStore } from '@/store/modules/app'
import { ThemeSwitch } from '@/layout/components/ThemeSwitch'
import { LocaleDropdown } from '@/layout/components/LocaleDropdown'

import { ImrLoginForm, RegisterForm, UstcLoginForm } from './components'

defineOptions({ name: 'Login' })

const { t } = useI18n()
const appStore = useAppStore()
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('login')
</script>

<style lang="scss" scoped>
$prefix-cls: #{$namespace}-login;

.#{$prefix-cls} {
  overflow: hidden;

  &.login-wrapper {
    position: relative;
    height: 100%;

    .login-wrapper-bg-video {
      //position: fixed;
      z-index: -1;
      position: absolute;
      top: 50%;
      left: 50%;
      min-width: 100%;
      min-height: 100%;
      width: auto;
      height: auto;
      transform: translate(-50%, -50%);
    }

    .login-container {
      position: relative;
      display: flex;
      flex-direction: column;
      margin: 0 auto;
      height: 100%;

      .login-header {
        position: fixed;
        display: flex;
        justify-content: space-between;
        padding: 20px;
        width: 100%;
      }
    }
  }

  &::after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    background: rgb(0, 0, 0, 0.7);
    content: '';
  }

  .login-form-wrapper {
    background: var(--login-form-bg-color);
    border-radius: 10px;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
  }

  :deep(.el-descriptions__body) {
    background: transparent !important;
  }

  :deep(.el-descriptions__header) {
    margin-top: 20px;
    margin-bottom: 10px;
  }
}

.light {
  .login-form-wrapper {
    --login-form-bg-color: rgba(255, 255, 255, 0.85);
  }
}

.dark {
  .login-form-wrapper {
    --login-form-bg-color: rgba(0, 0, 0, 0.1);
  }
}
</style>
